1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
// Project: VHDL to Verilog RTL translation
// Revision: 1.0
// Date of last Revision: February 27 2001
// Designer: Vincenzo Liguori
// vhd2vl test file
// This VHDL file exercises vhd2vl
// no timescale needed
module test(
input wire clk,
input wire rstn,
input wire en,
input wire start_dec,
input wire [2:0] addr,
input wire [25:0] din,
input wire we,
input wire [7:0] pixel_in,
input wire pix_req,
input wire config1,
input wire bip,
input wire [7:0] a,
input wire [7:0] b,
input wire [7:0] c,
input wire [7:0] load,
input wire [6:0] pack,
input wire [2:0] base,
input wire [21:0] qtd,
output wire [23:0] dout,
output reg [7:0] pixel_out,
output wire pixel_valid,
output reg [9:0] code,
output wire [9:0] code1,
output wire [23:0] complex,
output wire eno
);
// Inputs
// Outputs
// Components declarations are ignored by vhd2vl
// but they are still parsed
parameter [1:0]
red = 0,
green = 1,
blue = 2,
yellow = 3;
reg [1:0] status;
parameter PARAM1 = 8'b01101101;
parameter PARAM2 = 8'b11001101;
parameter PARAM3 = 8'b00010111;
wire [7:0] param;
reg selection;
reg start; wire enf; // Start and enable signals
wire [13:0] memdin;
wire [5:0] memaddr;
wire [13:0] memdout;
reg [1:0] colour;
assign param = config1 == 1'b1 ? PARAM1 : status == green ? PARAM2 : PARAM3;
// Synchronously process
always @(posedge clk) begin
pixel_out <= pixel_in ^ 8'b11001100;
end
// Synchronous process
always @(posedge clk) begin
case(status)
red : begin
colour <= 2'b00;
end
green : begin
colour <= 2'b01;
end
blue : begin
colour <= 2'b10;
end
default : begin
colour <= 2'b11;
end
endcase
end
// Synchronous process with asynch reset
always @(posedge clk, posedge rstn) begin
if(rstn == 1'b0) begin
status <= red;
end else begin
case(status)
red : begin
if(pix_req == 1'b1) begin
status <= green;
end
end
green : begin
if(a[3] == 1'b1) begin
start <= start_dec;
status <= blue;
end
else if(({b[5],a[3:2]}) == 3'b001) begin
status <= yellow;
end
end
blue : begin
status <= yellow;
end
default : begin
start <= 1'b0;
status <= red;
end
endcase
end
end
// Example of with statement
always @(*) begin
case(memaddr[2:0])
3'b000,3'b110 : code[9:2] <= {3'b110,pack[6:2]};
3'b101 : code[9:2] <= 8'b11100010;
3'b010 : code[9:2] <= {8{1'b1}};
3'b011 : code[9:2] <= {8{1'b0}};
default : code[9:2] <= (a) + (b);
endcase
end
assign code1[1:0] = a[6:5] ^ ({a[4],b[6]});
// Asynch process
always @(we, addr, config1, bip) begin
if(we == 1'b1) begin
if(addr[2:0] == 3'b100) begin
selection <= 1'b1;
end
else if(({b,a}) == {a,b} && bip == 1'b0) begin
selection <= config1;
end
else begin
selection <= 1'b1;
end
end
else begin
selection <= 1'b0;
end
end
// Components instantiation
dsp dsp_inst(
// Inputs
.clk(clk),
.rstn(rstn),
.en(en),
.start(start),
.param(param),
.addr(addr),
.din(din[23:0]),
.we(we),
.memdin(memdin),
// Outputs
.dout(dout),
.memaddr(memaddr),
.memdout(memdout));
mem dsp_mem(
// Inputs
.clk(clk),
.rstn(rstn),
.en(en),
.cs(selection),
.addr(memaddr),
.din(memdout),
// Outputs
.dout(memdin));
assign complex = {enf,3'b110 * (load),qtd[3:0],base,5'b11001};
assign enf = c < 7'b1000111 ? 1'b1 : 1'b0;
assign eno = enf;
endmodule
|