icestudio icon indicating copy to clipboard operation
icestudio copied to clipboard

feature: being able to use "normal" code

Open hasan12977 opened this issue 8 months ago • 8 comments

Is your feature request related to a problem? Please describe.

hello,

is it possible to use a normal code? like the one that has netlist on top?

I do use ai and ai does not know how to write code specifically for icestudio. basically, i do want to be able to copy and paste a code rather than editing things.

another example:

module up_counter_2bit ( input wire clk, // Clock input input wire reset, // Active-high reset output reg [1:0] count // 2-bit counter output );

// Counter logic always @(posedge clk or posedge reset) begin if (reset) begin count <= 2'b00; // Reset to 0 end else begin count <= count + 1; // Increment counter end end

endmodule

Describe the solution you'd like.

being able to use the code above in code frame.

Describe alternatives you've considered.

No response

Additional context

No response

hasan12977 avatar Mar 26 '25 15:03 hasan12977

Hi Hasan!, you could use code importer.

You need to add a code block from the option menu "Basic->Code" and in the "Tools tab" click on "import code" and follow the instructions.

You need to use the develop version from https://downloads.icestudio.io.

If you need more detailed help , tell me here.

cavearr avatar Mar 26 '25 15:03 cavearr

thanks for the reply. I do use macos and I have this version of the app. I guess that is why I cannot see code importer option. can you help me to download that version. I checked the link but could not find it for some reason.

Image

hasan12977 avatar Mar 26 '25 15:03 hasan12977

you are using stable version, that has not import options. If you want to use it (to avoid problems with unstable features), the use of verilog is very simple.

Icestudio encapsulate the "module", you only need to put a Basic->Code

Image

You could view something like this (this is for unstable version, in stable is the same with few many options):

Image

As you can see, i put your IO params in the right place, and be careful because icestudio swap the order for the bus widths (goes after the variable name). Then when you press ok, you see an editor and then you can put the content of your module, for example:

// Counter logic always @(posedge clk or posedge reset) begin if (reset) begin count <= 2'b00; // Reset to 0 end else begin count <= count + 1; // Increment counter end end

and this is all.

cavearr avatar Mar 26 '25 16:03 cavearr

I use the stable version they you showed. Hence me mentioning "code frame" or box in my original post. But I always get errors saying x variable is not a valid l value. In order to fix the issue I need to make a variable called x_reg, do the work on that. And in the end I have write assign x = x_reg;

I think if you try to build that code, you will get the same error

hasan12977 avatar Mar 26 '25 16:03 hasan12977

ah ok! sorry. In this version of icestudio there is no "output reg" , inputs and outputs are always wires (in the next release we support this kind of registered output).

In this way you need to define a new reg and assign with a wire, your code inside the block should be this:

//define a new register with a name similar than count
reg [1:0] counter;

// link count output wire to counter register
assign count = counter;

// Use your inner register "counter" as your initial count outuput reg
// Counter logic
always @(posedge clk or posedge reset) begin
if (reset) begin
counter <= 2'b00; // Reset to 0
end else begin
counter <= counter + 1; // Increment counter
end
end

With this the block should work.

cavearr avatar Mar 26 '25 16:03 cavearr

yes, I have to do that way for every module. it is especially problematic when there are 10-20 IO to the module.

do we know when the next release comes out?

another question, can i know why I don’t see any release for macos in here? https://downloads.icestudio.io/

hasan12977 avatar Mar 26 '25 17:03 hasan12977

Hi Hasan! the osx version at downloads.icestudio.io will be ready for the next week, I'm renewing Apple developer licenses and i'm with a bit of delay.

I'll recommend you to use the developement branch (download from https://downloads.icestudio.io ) is very stable and have a lot of improvements like automatic module import.

cavearr avatar Mar 26 '25 17:03 cavearr

can you help me to install it? the link you gave me above does not include that version.

hasan12977 avatar Mar 27 '25 19:03 hasan12977