`timescale 1ns / 1ps
module reg_with_load(clk, load, d_in, d_out);
input load;
input [3:0]d_in;
input clk;
output [3:0]d_out;
reg [3:0]d_out;
always @(posedge clk) begin
if(load==1) begin
d_out<= d_in;
end
end
endmodule
`timescale 1ns / 1ps
module reg_with_load(clk, load, d_in, d_out);
input clk;
input load;
input [3:0]d_in;
output [3:0]d_out;
reg [3:0]d_out;
always @(posedge clk) begin
case(load)
1'b1 : d_out <= d_in;
default : d_out <= d_out;
end
endmodule
`timescale 1ns / 1ps
module tb_reg_with_load();
reg load;
reg [3:0]d_in;
reg clk;
wire [3:0]d_out;
reg_with_load reg_with_load(clk, load, d_in, d_out);
always #5 clk=~clk;
initial begin
clk=1'b0; d_in=4'b0000; load=1'b1; #1
d_in=4'b0001; #10
d_in=4'b0010; #10
d_in=4'b0011; #10
d_in=4'b1111; #10
d_in=4'b0000; load=1'b0; #10
d_in=4'b0001; #10
d_in=4'b0010; #10
d_in=4'b0011; #10
d_in=4'b1111; #10
$finish;
end
endmodule
'Engineering(SoC Design) > Verilog' 카테고리의 다른 글
[복습] FSM - Coffee Machine (0) | 2022.03.13 |
---|---|
과거 실습과제 복습 (0) | 2022.03.13 |
Verilog (복습 1~3) (0) | 2022.03.11 |
블로그 설계독학-맛비 (0) | 2022.03.06 |
github, verilog category (0) | 2022.03.05 |