Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Community Forums
- :
- Forums
- :
- Vivado RTL Development
- :
- Simulation and Verification
- :
- Re: what is the difference between 4'b0000 and 000...

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

d4223738

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-29-2016 02:15 AM

7,271 Views

Registered:
04-18-2015

Hi,

I am a beginner of SystemVerilog. I am doing a very simple design, however, during the simulation in ModelSim,

whenever the input = 4'b(any 4bit value), e.g. input = 4'b0000, the output is correct.

whenever the input = (a 4 bit value), e.g. input = 0000, the output is incorrect.

Anyone could tell me why?

Best wishes,

Lei

1 Solution

Accepted Solutions

srimaye

Xilinx Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-29-2016 02:31 AM

10,987 Views

Registered:
09-25-2014

Hi @d4223738,

When you are assigning as input = 4'b(any 4bit value), it takes a 4 bit binary value. When you are assigning as the input = (a 4 bit value), it takes as a decimal value. For example :

for in1 = 4'b1111 , the value in binary is 000000000000000000000000000001111

for in1 = 1111 , the value in binary is 000000000000000000000010001010111

Thanks,

Srimayee

5 Replies

srimaye

Xilinx Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-29-2016 02:31 AM

10,988 Views

Registered:
09-25-2014

Hi @d4223738,

When you are assigning as input = 4'b(any 4bit value), it takes a 4 bit binary value. When you are assigning as the input = (a 4 bit value), it takes as a decimal value. For example :

for in1 = 4'b1111 , the value in binary is 000000000000000000000000000001111

for in1 = 1111 , the value in binary is 000000000000000000000010001010111

Thanks,

Srimayee

d4223738

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-29-2016 02:41 AM

7,252 Views

Registered:
04-18-2015

Hi,

Thank you for the reply.

In my case, both cases are all binary value. Please see the photo attached.

balkris

Xilinx Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-29-2016 03:01 AM

7,239 Views

Registered:
08-01-2008

This may be expected behavior . You may try running with some more input values

Thanks and Regards

Balkrishan

--------------------------------------------------------------------------------------------

Please mark the post as an answer "Accept as solution" in case it helped resolve your query.

Give kudos in case a post in case it guided to the solution.

Balkrishan

--------------------------------------------------------------------------------------------

Please mark the post as an answer "Accept as solution" in case it helped resolve your query.

Give kudos in case a post in case it guided to the solution.

d4223738

Adventurer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-29-2016 03:14 AM

7,236 Views

Registered:
04-18-2015

avrumw

Guide

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-29-2016 08:21 AM

7,198 Views

Registered:
01-23-2009

both cases are all binary value

That's exactly the point. Verilog supports constants in different bases - binary, octal, decimal and hexadecimal. With no specification the default is **decimal**.

So without a base specification

input = 1111;

This is interpreted as a decimal number - one thousand, one hundred and eleven.

With the base specification

input = 4'b1111;

This is interpreted as a binary number - the binary number 1111, which is the equivalent of 15 in decimal.

Avrum