Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

How Convert this system verilog code to verilog?

Status
Not open for further replies.

panda1234

Full Member level 2
Joined
Jan 22, 2015
Messages
125
Helped
4
Reputation
8
Reaction score
4
Trophy points
18
Activity points
1,172

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 4.38: testbench example 2
 
module testbench2();
  reg  a, b, c, y;
 
  // instantiate device under test
  sillyfunction dut(a, b, c, y);
 
  // apply inputs one at a time
  // checking results
  initial begin
    a = 0; b = 0; c = 0; #10;
    if (y === 1) else $error("000 failed.");
    c = 1; #10;
    assert (y === 0) else $error("001 failed.");
    b = 1; c = 0; #10;
    assert (y === 0) else $error("010 failed.");
    c = 1; #10;
    assert (y === 0) else $error("011 failed.");
    a = 1; b = 0; c = 0; #10;
    assert (y === 1) else $error("100 failed.");
    c = 1; #10;
    assert (y === 1) else $error("101 failed.");
    b = 1; c = 0; #10;
    assert (y === 0) else $error("110 failed.");
    c = 1; #10;
    assert (y === 0) else $error("111 failed.");
  end
endmodule

 
Last edited by a moderator:

mrflibble

Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,724
Helped
679
Reputation
1,360
Reaction score
651
Trophy points
1,393
Activity points
19,551
Looks like assert is the only statement you need to take care of. Several options:

The "who cares" option. Any decent simulator will handle SV these days. So if your simulator supports SV you could just use SV for your testbench and verilog for sysnthesis.

The "oh alright, I will Read The Fine Manual" option. Read the SV LRM, and see what assert does. Then you write a function or task in pure verilog to do the exact same thing.

And the ever popular "Google It" option. There probably already are people that did the RTFM option, and with a bit of luck there's some useable code floating around on the net.

Furthermore, if you are really really (no, really!) stuck with verilog for your verification work and still need assertions and all that, I suggest you read a bit here: http://www.asic-world.com/verilog/assertions.html
 
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top