Wednesday 12 October 2016

[11/10] Logisim - 4-bits Count-down w/ 4x J-K Flip Flops

For my Computer Organisation module, I implemented a 4-bits count-down circuit using four J-K Flip Flops. The counter counts down from 1010 (10 in decimal) to 0000 (0 in decimal).

The steps took were:
1. Find out for each current state, what the wanted next state is
2. For each of the states and the variables (bits, ABCD's) find the appropriate J and K values 
3. For each of the J, K values for each variable (bits - so that would be 8 in total), draw a Karnaugh map and find the min. SOP expression
4. Using the SOP expressions, implement the circuit - make sure the Q outputs head back to the LED's of the appropriate variable (bit)
5. Use the clock to count down

While I was building the circuit through Logisim, I realised that a JK Flip-Flop makes it convenient to handle multiple variables that are changing, because it has the 'toggle' command. For instance, if the current state is (0,0), you can either toggle it (J=1, K=1) or set J=1, K=0 to make the zeros change to one. Constructing my Karnaugh maps, I realised that this leads to simpler SOP expressions for each J's and K's, which led to a rather simple circuit as below!



Saturday 8 October 2016

[08/10] Ruby on Rails Workshop - Setting Up Nitrous.io & Framework Basics

Today I went to a HackerSchool workshop session by NUS Hackers. The framework for today's workshop was Ruby on Rails. The reason I decided to go to this workshop was because I wanted to learn a web framework that is being fairly widely used but also has a lot of good things to learn from. I'd heard that Ruby on Rails has a very interesting structure (which I learned today that it's called MVC) and I wanted to enhance my understanding of webs through this.

First I'm going to spend some more time understanding what MVC is.

MVC (Model - View - Controller) Framework

Source: https://www.youtube.com/watch?v=1IsL6g2ixak

  • It's an 'architectural paradigm' (1979) - it's not a framework!
  • It's used by: Ruby on Rails, Django, Lavavel, CakePHP etc
  • 'Model' is the data part. It takes care of all the data, rules, etc of the programme
  • 'View' is what is seen by the user. It shows all the outputs
  • 'Controller' receives input from the user and passes them as orders to the model
=> come to think of it, MVC reminded me of Swift (the views, the view controllers?) and it was no coincidence because what I was using for my CaloShare app (the cocoa app bits) was MVC. More info here: https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html

Benefits?
1. Clear structure (so structure is important)
2. No repeating

Some things I remember that were 'striking'(??) during today's workshop
1. Embedded Ruby within the HTML codes
2. The resource : command
3. Migrating
4. Routes - the instructor went through it briefly, but it's a very interesting concept and is crucial to understand for any framework. Route processing is basically leading the path to what the user requests. I learned the command 'rake routes' to check how the routes are configured.

Setting up Nitrous.io

The NUS Hackers team introduced this great tool called 'Nitrous' it's basically where you can easily code your prototypes without the hassle of setting up the individual languages or frameworks. 

Learning Ruby

The order's a bit mixed up, but I've also been learning the ruby language here:
http://tryruby.org/levels/3/challenges/1
Not very relevant to what I learned today but it's nice to know the language properly.

Next?

I followed the workshop pretty well today but I haven't understood the big overarching concept(s) and ideas of Rails yet. I think I'll start a tutorial on Youtube and build something simple as a practice.

https://www.youtube.com/playlist?list=PLw3DVCAvDGUtrWrm0s2zxnbrgzkG5YAfF