Lukáš Jiřiště [Thu, 14 Aug 2025 08:03:44 +0000 (10:03 +0200)]
Use a typedef and interface for part catalog
This may be an example of premature optimization. It however only adds
a couple of lines of code. It makes changing the underlying structure
easy to swap. And I think it is worth it. It is easy to go back with
substitution, but it would not necessarily be easy to introduce this
change later on.
Lukáš Jiřiště [Thu, 14 Aug 2025 07:11:07 +0000 (09:11 +0200)]
Add a third of the load command
The load command encompasses the language spec, its parsing and building
the circuit representation (and it also should create the graphics for
the loaded part).
In this commit only a part of the parsing is done (and the
prerequisites such as input handling).
This now correctly(?) parses the input file into a catalog of parts with
their dependencies.
I am sorry for the big (and yet incomplete) commit.
Lukáš Jiřiště [Sat, 21 Dec 2024 22:06:45 +0000 (23:06 +0100)]
Add wire (node) drawing to schema mode
Using the "c" key while in schema mode will start the drawing.
When it is started over an existing node, the node is extended, else new
node is created.
When ending on a node, the drawn node and the end node are merged
together.
To exit the mode use any other key than the movement keys (best use
"c"?).
To choose the correct symbol for a segment, the t_node_segment had to be
changed, and with that some functions (unrelated to wire drawing) had to
be changed also.
Lukáš Jiřiště [Sat, 21 Dec 2024 11:11:47 +0000 (12:11 +0100)]
Switch from pointers to IDs
Mosfets holding pointers to nodes (and nodes to mosfets) causes problems
when the nodes (or mosfets) vector reallocates. The reallocation
invalidates any pointers.
Holding the ID prevents the invalidation, but may cause performance
issues as the vector needs to be searched for the ID (binary search
would help and is applicable).
The IDs also make the code more networked, because the nodes and mosfets
vectors need to be passed to many more functions.
Lukáš Jiřiště [Fri, 20 Dec 2024 17:59:53 +0000 (18:59 +0100)]
Fix merge_nodes not transferring "gate mosfets"
Because mosfets were not listed in their gate nodes, they were bot
transferred during node merge.
This is fixed by adding a vector to node, that saves all mosfets
connected through gate.
The connected vector of node was not used, as the "gate mosfets" would
have to be filtered in simulation.
Lukáš Jiřiště [Fri, 20 Dec 2024 17:02:57 +0000 (18:02 +0100)]
Add some node graphics
When adding MOSFETs in the schema mode, a node is spawned for each of
the terminal. It is also bound and the terminal "position" is used for
its single segment.
I am not satisfied with how the position and symbol of this terminal
segment is obtained, but I cannot think about a more elegant way at this
time.
Lukáš Jiřiště [Wed, 18 Dec 2024 12:22:10 +0000 (13:22 +0100)]
Fix connect command
The problem was in the merge_nodes function, where a level of
indirection was missed - the vector connected (mosfets) of a node holds
pointers to mosfets, hence the ft_vec_access return t_mosfet**.
Lukáš Jiřiště [Wed, 18 Dec 2024 12:14:36 +0000 (13:14 +0100)]
Update Libft, switch to using IDs for objects
The ft_vec_find functions were updated, which necessitated some changes
in the code.
So now the nodes and MOSFETs use unique IDs instead of just their index
in the main vectors. Some hardening was done while switching.
Some minor bugs might also be present in this commit.
Lukáš Jiřiště [Sun, 15 Dec 2024 17:57:20 +0000 (18:57 +0100)]
Swap functionality of p- and n-channel FETs
I probably got confused when assigning the functionality.
We can be generous and say I'm switching the MOSFETS from depletion mode
to enhancement mode.
Lukáš Jiřiště [Sun, 15 Dec 2024 07:20:33 +0000 (08:20 +0100)]
Use ncurses library
Every printing function had to be replaced.
Color is handled differently.
A function was commented out, because I did not want to think about how
to integrate it now.
Lukáš Jiřiště [Fri, 16 Feb 2024 23:13:44 +0000 (00:13 +0100)]
Update Libft and use its feature to clean after gnl
Function get_next_line does not free all memory when reading from stdin
when it doesn't contain end of file. The new version of Libft makes it
possible to free the memory.
Lukáš Jiřiště [Fri, 16 Feb 2024 16:34:45 +0000 (17:34 +0100)]
Revert "Change t_mosfet to remember node id instead of ptr"
This reverts commit d03a1205f99244550c784b4c8c2694ae643f0278.
The commit was not thought through as it should. In addition it contains
some minor changes that should be recommited - that's why I should do
small commits that tend to a single problem/feature.
Lukáš Jiřiště [Sun, 4 Feb 2024 13:01:48 +0000 (14:01 +0100)]
Change t_mosfet to remember node id instead of ptr
This prevents looking for node id when drawing.
Some changes were present when I started this change. I can't really
tell, what they were, but from the diffs it looks like just 2 or 3 minor
cosmetic changes. Sorry.
Lukáš Jiřiště [Sun, 14 Jan 2024 16:42:57 +0000 (17:42 +0100)]
Add Libft/Makefile as dependency for %.c compilation
Add Libft/Makefile as an order-only-prerequisite for %.c files so that
after cloning the repository the Libft submodule is downloaded. This is
needed because without the Libft headers some files cannot be compiled.
Lukáš Jiřiště [Sun, 14 Jan 2024 16:34:41 +0000 (17:34 +0100)]
Add basic commands and refactor the code
Implement parsing of basic commands (help, next, add...)
-Mostly (?) as wrapper around function from previous commit
-It should be possible to do it in a much better way
Give the project some structure
-split main.c
-create src and inc directories
Lukáš Jiřiště [Sat, 13 Jan 2024 11:57:51 +0000 (12:57 +0100)]
Add TODO text file
The TODO list is quite short and not detailed. But better have it when it
is not needed yet than not have it when ideas are abundant. The
maintanance of TODO is so low it is worth adding.
Lukáš Jiřiště [Sat, 13 Jan 2024 10:55:36 +0000 (11:55 +0100)]
Start this project for simulating FET based logic
Add a small project capable(?) of simulating FET logic. Implement basic
structs and logic for the simulation.
Implement depicting of the simulation state.
Add submodule Libft for use in place of (most of) standard library.
- I develop this project for other reasons.
- This is an added challenge for learning's sake.
Add basics of project management (Makefile, .gitignore).