Parameters

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
BeS__284136
Level 3
Level 3
5 sign-ins 10 replies posted 5 replies posted

Hello,

I am attempting to set up a custom component that has verilog parameters that I want to read and write from in my firmware.

Verilog.pngpastedImage_1.png

I set up the parameters as formal.

My question is how do you I read and write values to these parameters in my C api? I did some searching and could not find and straight answers.

Thanks

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

BeS,

Parameters in the Verilog code above are "static", they are being passed from the Dialog menu to the Verilog code on startup and that's it. They can't be changed during the run-time. Of course, they can be read back in firmware, but it is not possible to change them; e.g. in ShiftMUX.h file:

#define `$INSTANCE_NAME`_REG0     `=$REG0`      // now REG0 is available to code

Generally, to have tunable parameter inside the Verilog code, a Control or Status Register should be instantiated inside the code and then it can be accessed using API like a standard Register. Please see basic example here

Re: how to transfer a value from c to a verilog component

Control_Status_Reg_instantiate_01_A.png

The issue in your case is that it needs 9 x 16-bit registers (each one constructed of 2x 8-bit register), total 18 registers. I am afraid that it will be hard to fit PSoC PLD space. Also note that writing to combined 16-bit register is not atomic, which can be an issue.

To test the design I would recommend to build a project using schematic first, where Registers are sitting outside the "Core" component ( written in Verilog) and connected by buses. If successful, design can be compacted into the Verilog.

/odissey1

View solution in original post

1 Reply
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

BeS,

Parameters in the Verilog code above are "static", they are being passed from the Dialog menu to the Verilog code on startup and that's it. They can't be changed during the run-time. Of course, they can be read back in firmware, but it is not possible to change them; e.g. in ShiftMUX.h file:

#define `$INSTANCE_NAME`_REG0     `=$REG0`      // now REG0 is available to code

Generally, to have tunable parameter inside the Verilog code, a Control or Status Register should be instantiated inside the code and then it can be accessed using API like a standard Register. Please see basic example here

Re: how to transfer a value from c to a verilog component

Control_Status_Reg_instantiate_01_A.png

The issue in your case is that it needs 9 x 16-bit registers (each one constructed of 2x 8-bit register), total 18 registers. I am afraid that it will be hard to fit PSoC PLD space. Also note that writing to combined 16-bit register is not atomic, which can be an issue.

To test the design I would recommend to build a project using schematic first, where Registers are sitting outside the "Core" component ( written in Verilog) and connected by buses. If successful, design can be compacted into the Verilog.

/odissey1