私はVerilogで非常に新しいです。 これは私の質問です:出力がオーバーラップしたときに出力に固執する種類
16ビットレジスタを持つ16ビットALUを実装します。このプロジェクトは、次の要件を満たす必要があります。
1. 16 bitALUを設計してください。 Xを入力として(例えばA、B ..)16ビットの結果を生成する16ビットALUを設計します.ALUは以下の機能を実行する必要があります。 ALUとLOGICの両方で5回以上の操作。
2. 16x16ビットのレジスタファイルを設計します。
3.コントロールユニットを設計します。
私の計画では、各モジュールに操作があるモジュールを作ります。それから私はテストベンチでそれを集める。しかし問題は今です。出力が重なり、赤とxになるようです。
これは私のAddモジュールです。
module Add(A,B,Y,S,clk,enb);
parameter BITS=8;
input clk,enb;
input [BITS - 5:0] S;
input [BITS - 1:0] A ,B;
output [BITS - 1:0] Y;
reg [BITS - 1:0] Y;
always @(posedge clk)
begin
if
((enb==1) || (S == 000))
begin
assign Y = A + B;
end
end
endmodule
Tolakモジュール(マイナスモジュール)
module Tolak(A,B,Y,S,clk,enb);
parameter BITS=8;
input clk,enb;
input [BITS - 5:0] S;
input [BITS - 1:0] A ,B;
output [BITS - 1:0] Y;
reg [BITS - 1:0] Y;
always @(posedge clk)
begin
if
((enb==1) || (S == 010))
begin
assign Y = A - B;
end
end
endmodule
Darabモジュール(乗算モジュール)
module Darab(A,B,Y,S,clk,enb);
parameter BITS=8;
input clk,enb;
input [BITS - 5:0] S;
input [BITS - 1:0] A ,B;
output [BITS - 1:0] Y;
reg [BITS - 1:0] Y;
always @(posedge clk)
begin
if
((enb==1) || (S == 011))
begin
assign Y = A * B;
end
end
endmodule
GateOrモジュール
module GateOr(A,B,Y,S,clk,enb);
parameter BITS=16;
input clk,enb;
input [BITS - 14:0] S;
input [BITS - 1:0] A ,B;
output [BITS - 1:0] Y;
reg [BITS - 1:0] Y;
always @(posedge clk)
begin
if
((enb==1) || (S == 011))
begin
assign Y = A | B ;
end
end
endmodule
GateAndモジュール
module GateAnd(A,B,Y,S,clk,enb);
parameter BITS=16;
input clk,enb;
input [BITS - 14:0] S;
input [BITS - 1:0] A ,B;
output [BITS - 1:0] Y;
reg [BITS - 1:0] Y;
always @(posedge clk)
begin
if
((enb==1) || (S == 100))
begin
assign Y = A & B;
end
end
endmodule
、これは私のテストベンチ
module Maintb();
parameter SIZE=8;
reg clk, enb ;
reg [SIZE-6:0] S;
reg[SIZE-1:0] A,B;
wire[SIZE-1:0] Y;
initial
begin
clk = 1'b0; enb = 1'b0;
end
// generate clock
always
begin
#(10) clk = !clk;
end
always begin
//#(10);
#10; enb = 1'b1; A=00000001; B=00000000; S=000; //add
#(10); enb = 1'b0;
#10; enb = 1'b1; A=00000001; B=00000000; S=001; //tolak
#(10); enb = 1'b0;
#10; enb = 1'b1; A=00000001; B=00000000; S=010; //darab
#(10); enb = 1'b0;
#10; enb = 1'b1; A=00000001; B=00000000; S=011; //or
#(10); enb = 1'b0;
#10; enb = 1'b1; A=00000001; B=00000000; S=100; //and
//#(10);
end
defparam dut.BITS = SIZE;
defparam dut1.BITS = SIZE;
defparam dut2.BITS = SIZE;
defparam gate.BITS = SIZE;
defparam gate1.BITS = SIZE;
Add dut (A,B,Y,S,clk,enb); //000
Tolak dut1 (A,B,Y,S,clk,enb); //001
Darab dut2 (A,B,Y,S,clk,enb); //010
GateOr gate (A,B,Y,S,clk,enb); //011
GateAnd gate1 (A,B,Y,S,clk,enb);//100
Endmodule
あなたのSは3ビットの一定のビット幅を持っていますか? –
あなたのenb信号の動作は何ですか? clkサイクルのエッジで変化するか、または任意のエッジで変化するか、またはclkサイクルとは独立しているか? –