Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

writing to a one bit register

Can a data register be one bit wide?

Thanks.

MS

6 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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).

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

    You need #include <stdbool.h>