![]() I/O device is given IOR and IOW control signals. I/O device has an 8 or 16 bit I/O address. I/O device is treated like a memory device and hence given a memory address. ![]() And the whole thing compiles to a single binary that doesn't even depend on libc - the stripped binary for the first example above is 872 bytes. I/O device is treated as an I/O device and hence given an I/O address. But we can easily guarantee that the metaprogramming is compiled away and the resulting code is statically type-checked. It can do the kinds of metaprogramming available in many dynamic languages - using the language itself rather than switching to a clunky type language. This puts zig in an interesting spot in the space of language design. zig : 39 : 17 : error : no member named 'inpot' in struct (old_value, field.name) = (new_value, field.name) So if we typo a field name we get a reasonable error at compile time. some builtin functions like require their arguments to be known at compile timeĪfter all of this compile-time evaluation and loop unrolling, the result is still statically type-checked.the argument to inline for or inline while must be known at compile time and their body is unrolled.if the argument to if or switch doesn't refer to any variables not known at compile time, the correct branch is inlined.So the question is what do we want the api to look like?įundamentally, an MMIO register is just a pointer to some specific address in memory: const Register = struct are evaluated at comptime Difference between Programmed I/O vs Memory Mapped I/O iniatinklis2022 m. The same information also exists in an accompanying xml file which we can use to generate a nice typed api. iniatinklisMemory mapped IO addresses are treated just like any other. ![]() And most times, the difference in performance between memory-mapping a file and doing discrete IO operations isn't all that much anyway. It's really hard to beat the simplicity of accessing a file as if it's in memory. Memory mapping files has a huge advantage over other forms of IO: code simplicity. The list of available registers is documented in a massive pdf for each board. One huge advantage of memory-mapped files. For example, on the nRF52833 board writing the value 0b11 to address 0x708 will set the 3rd GPIO pin to output mode and disconnect the input buffer. The major difference between them is that memory-mapped I/O devices share a common address space and instructions for both I/O devices and memory. I wanted to additionally highlight the api we used for memory-mapped IO registers because it shows off some nice features of zig.Īn MMIO register is just an address in memory where reads and writes are interpreted specially by the hardware. Kevin Lynagh and I spent some time playing around with zig on nrf52 boards. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |