Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

writing to a one bit register

Altera_Forum
Honored Contributor II
1,095 Views

Can a data register be one bit wide? 

Thanks.  

 

MS
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
354 Views

What exactly do you mean by this? 

 

Are you refering to Verilog? or VHDL? then yes. 

 

If you are refering to a C++ compiler, then I don't belive that C supports a 1 bit memory of any type. You can make a BOOL type, which is in a sense only 1 bit (on or off) however; the actuall implementation is larger than 1 bit. (Depending upon the compiler, I belive it can be as large as an Integer! Sheesh) 

 

If you want 1 bit memory out of the SOPC builder, I dont belive you can do that either. (may be possible, but I dont think any code could address it) 

 

Good luck.
0 Kudos
Altera_Forum
Honored Contributor II
354 Views

Sounds like you don't want to waste LE's, so yes you can. Simply use the lsb data bit (send either 0 or 1 to the register), and just store it in the register. One thing though is if you have a seperate software team, make sure they know it's a single bit being stored (if they try to store 2 they would be surprised to read back 0). Registers are simply D flipflops so you can make any width you like (the logic it feeds could experience a performance problem if the data is too wide depending on the implementation).

0 Kudos
Altera_Forum
Honored Contributor II
354 Views

I cannot use Boolean variables with the Nios IDE .. the compilation return an error when declaring a Boolean!

0 Kudos
Altera_Forum
Honored Contributor II
354 Views

What error do you have? There isn't any problem using booleans in C/C++. It is a standard type in C++, but in C you need to create it with a typedef.

0 Kudos
Altera_Forum
Honored Contributor II
354 Views

I didn't know that C doesn't support that type! 

thanks ..
0 Kudos
Altera_Forum
Honored Contributor II
354 Views

My colleague use bool type for some variables. But I think it takes at least 1 Bytes in memory. 

You need #include <stdbool.h>
0 Kudos
Reply