8 bit micro controller by verilog

Status
Not open for further replies.

vead

Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Visit site
Activity points
3,815
I am a student and want learn by doing some work I want design 8 bit micro controller by verilog coding I know its very hard question but I need your help I want to start with basic as my knowledge I know little verilog programming

example

module modulename (input port, output port);
input port= ;
output port=;
begin



endmodule

1)so my question how to write input and output value for 8 bit controller
2) what will be input and output
3) what I need to know extra
 

Re: verilog code for microcontroller

I'm pretty sure that there're a lot of easier things to go with "learn by doing". Start with turning on a Led, then create a secuence, then add a button, then more leds.
 

Re: verilog code for microcontroller

I'm pretty sure that there're a lot of easier things to go with "learn by doing". Start with turning on a Led, then create a secuence, then add a button, then more leds.
thaks for reply but that's not my question so please read what I am saying
 

Re: verilog code for microcontroller

Try looking on opencores.org for some CPU core examples. If nothing else that will give you some new questions, for which you then can use google to work out 90%. For the last 10% you cannot figure out for your design you use a forum. Good luck!
 

Re: verilog code for microcontroller

thaks for reply but that's not my question so please read what I am saying

True, i just understood from the post that you wanted to learn by doing and i believe that designing a microcontroller is not an easy way.Just an opinion.

Now, with your question i guess that opencores, as mrfibble says, could show you some good examples but first i would say that you should dig more into microcontrollers architecture. Once you decide which architecture you want to implement, go ahead and try to do it in verilog.
 


Re: verilog code for microcontroller

5 seconds and 3 mouse clicks if you actually want the design files for picoblaze...

BTW the RTL is not encrypted.

- - - Updated - - -

That J1 should use an inferred synchronous RAM block so it can be easily ported between FPGA vendors.
 

Re: verilog code for microcontroller

Heheh, I already have picoblaze. I needed 5 seconds and 2 clicks for the j1 verilog source, all 187 lines of it.

And it uses RAMB16_S2_S2 primitives, but that is easy enough to change to something portable..
 

Re: verilog code for microcontroller

And another fine learning opportunity lost.
 

Re: verilog code for microcontroller

j1 verilog source, all 187 lines of it.

Without all that wasteful white space it's only 41 lines of "real" code. ;-)

It could have been a very efficient 1 line of code, if they had properly used /**/ comments. ;-)
 

Re: verilog code for microcontroller

Without all that wasteful white space it's only 41 lines of "real" code. ;-)

It could have been a very efficient 1 line of code, if they had properly used /**/ comments. ;-)

Heheh. It is a bit verbose, but not overly so IMO. As in it is easy to read and comprehend. Not something that can be said all that often about free code in the wild.

You would probably really hate my verilog codin style then. I also put the module port declarations on seperate lines. As opposed to putting it on two lines line in j1.v.

With that said, is there something like a style guide I could read to improve things?
 

Re: verilog code for microcontroller

I have downloaded code but I didn't understood code , In verilog code we define the module name , input and output but how to define for controller microcontroller contain many module like ALU, decoder RAM, rom, counter ......etc how to start
 

Re: verilog code for microcontroller

Read the fine paper. Maybe pbernardi can provide you with the link that is right on the website as well.
 

Re: verilog code for microcontroller


I've developed my own style of coding from years of working and it typically requires the use of 1 port=1 line of code with a comment on the end of the line to define what that ytxfpno_nstvyg signal name means. (Of course my coding style forbids cryptic names like that with Hungarian/Romanian/Ukrainian/etc notation nonsense).

Pretty much all of my coding style guidelines I use are directly related to maintainability and code reuse. I also use only 2 spaces (real spaces) for all indentation as I dislike having to scan across 4 and 8 (space) tabs. Don't get me started on those ilk that love to use tabs and spaces in the same file for indentation (drawn and quartered is not a severe enough penalty for them) ;-)

Actually the fact that the processor is a functional 8-bit processor in less than 187 lines of actual code was very interesting. I was going to look it over in more detail to see how it was structured and what it's capabilities are. It's certainly smaller than the picoblaze, of course pico isn't written very behaviorally, so maybe it's only 1 line of behavioral code. ;-)
 

Re: verilog code for microcontroller

Yup, that's why I do the single line per port as well. That way you can add a short & sweet comment describing what that signal does.

As for the "No Ukranian notation" XD, how do you handle things like active low, asynchronous, metastables, stuff like that? For example, for an async reset that's active low, I would use rst_async_n.

And for metastables, if they are part of the functionality, and it's important that I know it is metastable, then I use my_signal_meta for the metastable part, and my_signal after synchronization.

Well, it's 4 spaces over here. If I have to intend so much that I cannot read it anymore then that is a big hint that I should probably write it a bit differently. And indeed, those that mix tabs + spaces need to get out and shot. Mmmh, shoot first, then be drawn & quartered, or drawn & quartered, and then shot. And then tarred & feathered. And THEN run out of town naked. That'll teach 'm to be fruit baskets.

Heheh, 1 line of behavioral, depending on comment style no doubt. ;-) But yes, it is indeed an interesting bit of code. I have it on the Stuff To Read [tm] list as well, to see what can be learned from it.
 

Re: verilog code for microcontroller


You know, I have a more direct approach to stuff like this. First, FGPA is HW, so I avoid to name wires and registers like variable, and try to use capital letters, as for example, a component pin would be named. In your example, I would probably name the wire as RES, or maybe with ARES if I already have other reset.


Well, I have the bad habit to mix spaces and tabs sometimes, so I have a real mess in my codes sometimes, specially if the code is opened in other text editor. :-?


It is indeed very interesting. But that FORTH thing, this is odd. the controller is easy to understand, but I cannot write few lines of FORTH, I think I have some kind of block in my mind.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…