EDA Playground lets you type in and run HDL code (using a selection of free and commercial simulators and synthesizers).
It's great for learning HDLs, it's great for testing out unfamiliar things and it's great for sharing code.
You can start typing straight away. But to run your code, you'll need to sign or log in. Logging in with a Google account gives you access to all non-commercial simulators and some commercial simulators:
To run commercial simulators, you need to register and log in with a username and password. Registration is free, and only pre-approved email's will have access to the commercial simulators.
* Icarus Verilog 0.9.7 not available.
208
// Code your testbench here
// or browse Examples
`default_nettype none
module tb_counter;
reg clk;
reg rstn;
wire [3:0] out;
counter uut(clk,rstn,out);
// Generate a clock that should be driven to design
// This clock will flip its value every 5ns -> time period = 10ns -> freq = 100 MHz
always #5 clk = ~clk;
// This initial block forms the stimulus of the testbench
initial
begin
clk <= 0;
rstn <= 0;
#20
rstn <= 1;
#80
rstn <= 0;
#50
rstn <= 1;
#200
$finish;
end
initial begin
$dumpvars(0,uut);
$dumpfile("dump.vcd");
end
endmodule
xxxxxxxxxx
// Code your design here
`default_nettype none
module counter ( input clk,
input rstn,
output reg[3:0] out); // Declare 4-bit output port to get the counter values
// This always block will be triggered at the rising edge of clk (0->1)
// Once inside this block, it checks if the reset is 0, if yes then change out to zero
// If reset is 1, then design should be allowed to count up, so increment counter
always @ (posedge clk) begin
if (rstn <= 0)
out <= 0;
else
out <= out + 1;
end
endmodule
//look up how to generate clock in FPGA
//https://www.edaplayground.com/x/rux
Your account is not validated. If you wish to use commercial simulators, you need a validated account.
If you have already registered (or have recently changed your email address), but have not clicked on the link in the email we sent you, please do so. If you cannot find the email, please check your spam/junk folder. Or click here to resend the email.
If you have not already registered for a full account, you can do so by clicking below. You will then need to provide us with some identification information. You may wish to save your code first.
Creating, deleting, and renaming files is not supported during Collaboration. To encourage development of these features for Collaboration, tweet to @EDAPlayground
This playground may have been modified. Please save or copy before starting collaboration.
Your exercise has been submitted.