我找到了温度解码器的这个verilog代码(在代码编码器中,但这是错误的)。
我想调整它的节奏,从中生成一个网表。我的问题是,实际代码以节奏生成 [7:0] + 1 输入和 [3:0] 输出。
我想要的是一个具有 8 + 1 个单输入和 4 个单输出的模块:
module thermometer_encoder_8bit(
out0,out1,out2,out3, // 4-bit binary Output
in0,in1,in2,in3,in4,in5,in6,in7, // 8-bit Input
enable // Enable for the encoder
);
input enable;
input in0,in1,in2,in3,in4,in5,in6,in7;
output out0,out1,out2,out3;
reg out0,out1,out2,out3;
...
这是实际的,未改编的代码:
module thermometer_encoder_8bit(
binary_out , // 4 bit binary Output
encoder_in , // 8-bit Input
enable // Enable for the encoder
);
output [3:0] binary_out ;
input enable ;
input [7:0] encoder_in ;
reg [3:0] binary_out ;
always @ (enable or encoder_in)
begin
binary_out = 0; // 0000 0000
if (enable) begin
case (encoder_in)
8'b00000001 : binary_out = 1; // 0000 0001
8'b00000011 : binary_out = 2; // 0000 0011
8'b00000111 : binary_out = 3; // 0000 0111
8'b00001111 : binary_out = 4; // 0000 1111
8'b00011111 : binary_out = 5; // 0001 1111
8'b00111111 : binary_out = 6; // 0011 1111
8'b01111111 : binary_out = 7; // 0111 1111
8'b11111111 : binary_out = 8; // 0000 1111
endcase
end
end
endmodule
有没有可能,以一种简单的方式做到这一点?
问候,达荷马