add SV example

This commit is contained in:
2021-06-09 11:26:43 +02:00
parent e71d8eb717
commit c08ef2102f
16 changed files with 678 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
//////////////////////////////////////////////////////////////
// 4-bit loadable up-down counter //////
//////////////////////////////////////////////////////////////
module counter(clk, rst, data, updown, load, data_out);
input clk, rst, load;
input updown;
input [3:0] data;
output reg [3:0] data_out;
always@(posedge clk)
begin
if(rst)
data_out <= 4'b0;
else if(load)
data_out <= data;
else
data_out <= ((updown)?(data_out + 1'b1):(data_out -1'b1));
end
endmodule